热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

`Post`in0.9.0

Whathappened?Generateisturningthefollowingschema:


What happened?

Generate is turning the following schema:

1
2
3
4
5
6
7
type Post {

        id: Int!

}



type Article {

    posts: [Post!]!

}

into:

1
2
3
4
5
6
7
type Post struct {

        ID         int        `json:"id"`

}



type Article {

     Posts         []*Post        `json:"posts"`

}


What did you expect?

I expected the following generated types, which has been the case with previous versions:

1
2
3
4
5
6
7
type Post struct {

        ID         int        `json:"id"`

}



type Article {

     Posts         []Post        `json:"posts"`

}

That is, I expected

1
[Post!]!

to become

1
[]Post

not

1
[]*Post

. I cannot tell whether this is intentional, based on #710 and #711, or not.

Minimal graphql.schema and models to reproduce

See above.

versions



  • 1
    gqlgen version

    ? 0.9.0



  • 1
    go version

    ? 1.12.0


  • dep or go modules? go modules

该提问来源于开源项目:99designs/gqlgen

This was intentional, see #710



It makes gqlgen more consistent with other codegen tools like prisma and protobuffer and generally reduces boilerplate.

See also #375 (comment)



I am using Prisma and the methods always return a slice of structs, not pointers, so I have to retype it every time, or am I doing something wrong? My issue: (https://github.com/99designs/gqlgen/issues/738)


   



推荐阅读
author-avatar
瑞风大姑娘_214
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有